import { createStore } from 'vuex'

interface State {
  userName: string
  taskList: any[]
}

export default createStore({
  state: {
    userName: '郝小娟',
    taskList: []
  },
  mutations: {
    creatTask (state: any, payload: any) {
      state.taskList.push(payload)
    },
    updateTask (state: any, payload: any) {
      let {index, flag} = payload
      state.taskList[index].isfinished = flag
    },
    deleteTask (state: any, payload: any) {
      state.taskList.splice(payload, 1)
    }
  }
})